{include file="./layout/header.html" /}
<body>
<div class="x-nav">
  <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:left" onClick="javaScript:history.go(-1)" title="返回">
    <i class="layui-icon" style="line-height:30px">&#xe65c;</i></a>

  <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
  <div class="layui-row">
    <form class="layui-form layui-col-md12 x-so">
      <input class="layui-input" placeholder="开始日" name="start" id="start">
      <input class="layui-input" placeholder="截止日" name="end" id="end">
      <input type="text" name="username"  placeholder="请输入用户名" autocomplete="off" class="layui-input">
      <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
    </form>
  </div>
  <xblock>
    <input type="hidden" id="sid" value="{$sid}">
    <input type="hidden" id="hotel_id" value="{$hotelid}">
    <!--<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>-->
    <button class="layui-btn" onclick="x_admin_show('添加','{:url("Conferroomtype/create")}?sid={$sid}&hotelid={$hotelid}')"><i class="layui-icon"></i>添加</button>
    {present name="$total"}
    <span class="x-right" style="line-height:40px">共有数据：<span >{$total}</span> 条</span>
    <input type="hidden" id="total" value="{$total}">
    {/present}
  </xblock>
  <table class="layui-table">
    <thead>
    <tr>
      <th>
        <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
      </th>
      <th>排序</th>
      <th>货币类型</th>
      <th>费用名称</th>
      <th>标准费用</th>
      <th>描述</th>
      <th>添加时间</th>
      <th>状态</th>
      <th>操作</th>
    </thead>
    <?php $num = 0 ?>
    <tbody id="contentbody">
    {volist  name="intrs.0.intr" id="v"}
    <tr>
      <td>
        <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
      </td>
      <td><?php echo $num; $num++; ?></td>
      <td>{$v->translations[1]->currency}</td>
      <td>{$v->translations[1]->name}</td>
      <td>{$v->translations[1]->price}</td>
      <td>{$v->translations[1]->description}</td>
      <td><?php echo  date("Y-m-d H:i",$v->translations[1]->created_at)?></td>

      <td class="td-status">
        {if condition="$v->status eq 1"}
        <span class="layui-btn layui-btn-normal layui-btn-mini">已启用</span>
        {else /}
        <span class="layui-btn layui-btn-normal layui-btn-mini layui-btn-disabled">已停用</span>
        {/if}
      </td>

      <td class="td-manage">
        <a onclick="member_stop(this,'10001')" href="javascript:;"  title="启用">
          <i class="layui-icon">&#xe601;</i>
        </a>
        <a title="编辑"  onclick="x_admin_show('编辑','{:url("Conferroomtype/details",array("hotelid"=>$intrs[0]["hotelid"] ,"id"=>$v->uid,"sid"=>$intrs[0]["sid"]))}')" href="javascript:;">
        <i class="layui-icon">&#xe642;</i>
        </a>
        <a title="删除" onclick='member_del(this,"{$intrs.0.hotelid}","{$v->uid}","{$intrs.0.sid}")' href="javascript:;"><i style="font-size: 17px;" class="layui-icon">&#xe640;</i></a>
      </td>

    </tr>
    {/volist}
    </tbody>
  </table>
  <div class="page">
    <div id="demo3"></div>
  </div>

</div>


<script>
    /*用户-删除*/
    function member_del(obj,hotelid,id,sid,lang){

        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $.ajax({
                dataType : 'json',
                type : 'POST',
                url : '{:url("Conferroomtype/delete")}',
                async: false,
                data : {hotelid:hotelid,id:id,sid:sid,lang:lang},
                success : function(msg){
                    layer.alert(msg.msg, {icon: 6},function () {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    });
                },
                error : function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status + "," + textStatus);
                }
            });
        });
    }

    //分页
    var total = $("#total").val()
    layui.use(['laypage', 'layer'], function() {
        var laypage = layui.laypage
            , layer = layui.layer;
        console.log(total);
        //自定义首页、尾页、上一页、下一页文本
        laypage.render({
            elem: 'demo3'
            , count: total
            , limit:10
            , first: '首页'
            , last: '尾页'
            , prev: '<em>←</em>'
            , next: '<em>→</em>'
            ,jump: function(obj, first){
                //obj包含了当前分页的所有参数，比如：
                console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                console.log(obj.limit); //得到每页显示的条数
                var page = obj.curr;
                var limit = obj.limit;
                var hotelid = $("#hotel_id").val();//获取当前酒店id
                var sid = $("#sid").val();//获取当前站点id
                //首次不执行
                if(!first){
                    //do something
                    //发异步请求下一页数据
                    $.ajax({
                        dataType : 'json',
                        type : 'POST',
                        url : '{:url("Conferroomtype/list")}?hotelid='+hotelid+'&sid='+sid,
                        async: false,
                        data : {page:page,limit:limit},
                        success : function(data){
                            console.log(data);
                            integratingData(data);

                            $(".xxkk").mouseover(function() {
                                var val=$(this).attr("id");
                                $("."+val).addClass("layui-show");
                            });

                            $(".xxkk").mouseout(function() {
                                var val=$(this).attr("id");
                                $("."+val).removeClass("layui-show");
                            });

                        },
                        error : function(XMLHttpRequest, textStatus, errorThrown) {
                            alert(XMLHttpRequest.status + "," + textStatus);
                        }
                    });
                }
            }
        });
    })

    function  integratingData(data){

        var html = '';
        for(var i=0;i<data[1].length;i++){
            html+=
                '<tr>'+
                '<td><div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id="2"><i class="layui-icon">&#xe605;</i></div></td>' +
                '<td>'+i+'</td>'+
                    '<td>' + data[1][i].translations[1].currency + '</td>' +
                    '<td>' + data[1][i].translations[1].name + '</td>' +
                    '<td>' + data[1][i].translations[1].price + '</td>' +
                    '<td>' + data[1][i].translations[1].description + '</td>' +
                    '<td>' + data[1][i].translations[1].created_at + '</td>' +
                '<td class="td-status">';
            if(data[1][i].status == 1){
                html+=
                    `<span class="layui-btn layui-btn-normal layui-btn-mini">已启用</span>`+
                    `</td>`+
                    `<td class="td-manage">`+
                    `<a onclick="member_stop(this,10001)" href="javascript:;"  title="启用">`+
                    `<i class="layui-icon">&#xe601;</i>`+
                    `</a>`+
                    `<a title="编辑"  onclick=(` +
                    `x_admin_show('编辑',`+
                    `'{:url("Conferroomtype/details")}?hotelid=`+data[0].hotelid+`&id=`+data[1][i].uid+`&sid=`+data[0].sid+
                    `')) href="javascript:;">`+
                    `<i class="layui-icon">&#xe642;</i>`+
                    `<span class="layui-nav-more"></span></a>`+
                    `<a title="删除" onclick="member_del(this,'` +
                    data[0].hotelid+
                    `','` + data[1][i].uid +
                    `','` + data[0].sid +
                    `')" href="javascript:;">`+
                    '<i class="layui-icon">&#xe640;</i>'+
                    '</a>'+
                    '</td>'+
                    '<tr>';
            }else{
                html+=
                    `<span class="layui-btn layui-btn-normal layui-btn-mini">已停用</span>`+
                    `</td>`+
                    `<td class="td-manage">`+
                    `<a onclick="member_stop(this,10001)" href="javascript:;"  title="启用">`+
                    `<i class="layui-icon">&#xe601;</i>`+
                    `</a>`+
                    `<a title="编辑"  onclick=(` +
                    `x_admin_show('编辑',`+
                    `'{:url("Conferroomtype/details")}?hotelid=`+data[0].hotelid+`&id=`+data[1][i].uid+`&sid=`+data[0].sid+
                    `')) href="javascript:;">`+
                    `<i class="layui-icon">&#xe642;</i>`+
                    `<span class="layui-nav-more"></span></a>`+
                    `<a title="删除" onclick="member_del(this,'` +
                    data[0].hotelid+
                    `','` + data[1][i].uid +
                    `','` + data[0].sid +
                    `')" href="javascript:;">`+
                    '<i class="layui-icon">&#xe640;</i>'+
                    '</a>'+
                    '</td>'+
                    '<tr>';
            }
        }
        $('#contentbody').html(html);

    }
</script>
{include file="./layout/footer.html" /}